package json.jackson;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

public class JackSontest {

	public static void main(String[] args) throws JsonGenerationException, JsonMappingException, IOException {
		ObjectMapper mapper = new ObjectMapper();

//		mapper.setVisibility(JsonMethod.FIELD, Visibility.ANY);
//
//		people person = new Person("Unmi", new Address("JiangXi"));
		People person1=new People(11, new Address("aaa"));
//		People person2=new People(22, new Address("bbb"));
		Address person2 =new Address("aaa");

		List<Object> list=new ArrayList<Object>();
		list.add(person1);list.add(person2);
		
		All all=new All();
		all.setAll("xxx");
		all.setList(list);
		String json = mapper.writeValueAsString(all);
		System.out.println(json);
		
//		People pp=mapper.convertValue(json, People.class);
		All a=mapper.readValue(json, All.class);
		System.out.println(a.getAll()+";");
	}

}
